package ttsolver.constraints;

import ttsolver.input.Train;

public class ConsDeparture extends DefaultConstraint {
	
	private Train train;
	
	public ConsDeparture() {
		super(ConstraintType.CONS_DEPARTURE);
	}	
	
	public ConsDeparture(Train train){
		super(ConstraintType.CONS_DEPARTURE);
		this.train = train;
	}
	
	public Train getTrain() {
		return train;
	}

	public void setTrain(Train train) {
		this.train = train;
	}

	@Override
	public int hashCode(){
		final int prime = 31;
		int result = 1;
		result = prime * result + ((train == null)? 0 : train.getId().intValue());
		return result;
	}
	
	@Override
	public boolean equals(Object obj){
		if(this == obj)
			return true;
		if(obj == null)
			return false;
		if(getClass() != obj.getClass())
			return false;
		
		ConsDeparture other = (ConsDeparture) obj;
		
		if(train == null){
			if(other.train != null)
				return false;
		}else if(!train.equals(other.train)){
			return false;
		}
		
		return true;
	}
	
	@Override
	public String toString(){
		String s = "";
		s += (train != null)? train.getId() : "N/A";
		return "Partida_(" + s + "):\n";
	}

}
